package com.sc.javaee.service.impl;

import com.sc.javaee.mapper.UsersMapper;
import com.sc.javaee.pojo.Users;
import com.sc.javaee.service.userService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class userServiceImpl implements userService {
    @Autowired
    UsersMapper mapper;

    @Override
    public Users login(Users u) {
        return mapper.login(u);
    }

    @Override
    public int add(Users u) {
        return mapper.insertSelective(u);
    }

    @Override
    public int update(Users u) {
        return mapper.updateByPrimaryKeySelective(u);
    }

    @Override
    public Users select(Integer Id) {
        return mapper.selectByPrimaryKey(Id);
    }

    @Override
    public int delete(Integer id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public boolean isPhoneExists(String phone) {
        return mapper.countByPhone(phone) > 0;
    }
}
